package com.suntop.carousel.qlmediaplay.danmu;

import android.content.Context;
import android.util.AttributeSet;
import android.view.animation.Transformation;
import android.view.animation.TranslateAnimation;

public class MyTranslateAnimation extends TranslateAnimation {

    private TranslateAnimationListener listener;
    private int tag=0;

    public MyTranslateAnimation(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public MyTranslateAnimation(float fromXDelta, float toXDelta, float fromYDelta, float toYDelta) {
        super(fromXDelta, toXDelta, fromYDelta, toYDelta);
    }

    public MyTranslateAnimation(int fromXType, float fromXValue, int toXType, float toXValue, int fromYType, float fromYValue, int toYType, float toYValue) {
        super(fromXType, fromXValue, toXType, toXValue, fromYType, fromYValue, toYType, toYValue);
    }

    @Override
    protected void applyTransformation(float interpolatedTime, Transformation t) {
        super.applyTransformation(interpolatedTime, t);
        if (listener!=null){
            float[] point=new float[9];
            t.getMatrix().getValues(point);
            listener.onAnimationUpdate(tag,point[2],point[5]);
        }
    }

    public void setTag(int tag) {
        this.tag = tag;
    }

    public void setUpDateListener(TranslateAnimationListener listener) {
        this.listener = listener;
    }
}
